package com.demo.spring.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

public interface CusCacheService {

    Object save(String key,Object value);

    Object get(String key);

    void remove(String key);

    @Slf4j
    @Service
    class Default implements CusCacheService {

        @Override
        @CachePut(cacheNames="CusCacheService",key="'obj:'+#key")
        public Object save(String key,Object value){
            return value;
        }

        @Override
        @Cacheable(cacheNames="CusCacheService",key="'obj:'+#key")
        public Object get(String key) { return null; }

        @Override
        @CacheEvict(cacheNames="CusCacheService",key="'obj:'+#key")
        public void remove(String key) {}

    }

}
